package com.cf.r1032_ak;

import java.io.*;
import java.util.*;

public class f {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StreamTokenizer in = new StreamTokenizer(br);
        PrintWriter out = new PrintWriter(System.out);
        in.nextToken(); int T = (int) in.nval;
        while (T-- > 0) {
            in.nextToken(); int n = (int) in.nval;
            in.nextToken(); long s = (long) in.nval;
            in.nextToken(); long x = (long) in.nval;
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                in.nextToken(); a[i] = (int) in.nval;
            }

            long ans = 0L;
            for (int i = 0; i < n; ) {
                if (a[i] > x) {
                    i++;
                    continue;
                }
                int ei = i + 1;
                while (ei < n && a[ei] <= x) ei++;
                int[] b = new int[ei - i];
                for (int j = i, k = 0; j < ei; j++, k++) b[k] = a[j];
                ans += proc(b, x, s);
                i = ei;
            }
            out.println(ans);

        }
        out.flush();
        out.close();
        br.close();
    }

    public static long proc(int[] a, long x, long s) {
        int n = a.length;
        long[] pre = new long[n];
        for (int i = 0; i < n; i++) {
            pre[i] = a[i] + (i > 0 ? pre[i - 1] : 0);
        }
        long res = 0;
        Map<Long, Integer> c = new HashMap<>();
        for (long v : pre) c.put(v, c.getOrDefault(v, 0) + 1);

        int head = 0;
        for (int i = 0; i < n; i++) {
            while (head < i || (head < n && a[head] < x)) {
                long key = pre[head];
                int cnt = c.getOrDefault(key, 0) - 1;
                if (cnt > 0) c.put(key, cnt);
                else c.remove(key);
                head++;
            }
            long need = (i > 0 ? pre[i - 1] : 0) + s;
            res += c.getOrDefault(need, 0);
        }
        return res;
    }

}
